<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>首页</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js" ></script>
</head>
<body>
<center>
<form action="login" method="post">
	<h2>登陆</h2>
	<h4>账号:<input type="text" name="uname" id="uname" onblur="check()" /> <div id="error"></div></h4> 
	<h4>密码:<input type="password" name="upwd" id="upwd" /></h4>
	<h4><input type="submit" value="登陆" /> </h4>
</form>
<h4><input type="button" value="注册" /></h4>
</center>

<script type="text/javascript" >

	function check(){
		var name = $("#uname").val();
		
		$.ajax({
			type:"post",
			url:"check",
			data:name,
			datatype:"json",
			success:function (msg){
					if(msg.sta == "1"){
						$("#error").html("用户不存在!");
						}
					if(msg.sta == "0"){
						$("#error").html("用户存在!");
						}
				}
			});
	}
</script>

</body>
</html>